<template>
	<view>
		<view>
			<swiper class="swiper" :circular="true" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
			 :duration="duration">
				<swiper-item v-for="item in banner">
					<image class="banner1" :src="item.img_url"></image>
				</swiper-item>
			</swiper>
		</view>
		<view class="header">
			<view class="header1">
				<image src="../../static/icons/chat.png"></image>
			</view>
			<view class="header1">推荐</view>
			<view class="header2">
				<image src="../../static/icons/search.png"></image>
			</view>
			<view class="header3">
				<image src="../../static/icons/cart.png"></image>
			</view>
		</view>
		<view class="pltj">
			<view class="pltj1">品类推荐</view>
			<view class="pltj2">更多 ></view>
		</view>
		<view class="xh1">
			<view class="white" v-for="item in list1">
				<image :src="item.cover_img"></image>
				<view>{{item.descr}}</view>
			</view>
		</view>
		<view class="pltj">
			<view class="pltj1">特色优选</view>
		</view>
		<swiper previous-margin="15px" next-margin='20px' class="swiper"  :interval="interval" :duration="duration">
			<swiper-item v-for="item in brondlist" @tap="xq(item.id)">
				<view class="bg">
				<image class="img" :src="item.cover_img"></image>
				<view>
					<view class="bg3">{{item.descr}}</view>
					<view class="bg4">{{item.detail_desc}}</view>
					<view v-for="subItem in item.colors">
						<view class="color-item" :style="{'background-color':subItem}"></view>
						<!-- <text>{{subItem}}</text> -->
					</view>
					<view>{{item.gname}}</view>
				</view>
				</view>
			</swiper-item>
		</swiper>

	</view>
</template>

<script>
	import {
		banners
	} from "../../util/home/index.js";
	import {
		hotList
	} from "../../util/home/index.js";
	import {
		productList
	} from "../../util/home/index.js";
	import {
		brandList
	} from "../../util/home/index.js";
	export default {
		data() {
			return {
				background: ['color1', 'color2', 'color3'],
				indicatorDots: true,
				autoplay: true,
				interval: 2000,
				duration: 500,
				banner: [],
				brondlist:[],
				list1: [],
				list2: [],
				a:'',
				b:'',
				c:''
			}
		},
		onLoad(val) {
			//轮播图接口
			banners({
					use: 0,
				})
				.then(res => {
					console.log(res)
					this.banner = res.data.data
				})
			//特色优选接口
			hotList()
				.then(res => {
					console.log('res',res) 
					this.brondlist = res.data.data;
					var list = res.data.data
					for(var i=0;i<list.length;i++){
						if(i==5||i==12||i==13){
							this.list1.push(list[i])
						}
					}
				})
				
		},
		methods: {
			xq(val){
				console.log(val)
				uni.navigateTo({
					url:`homeinfo/homeinfo?id=${val}`
				})
			}
		},
		onShow () {
			console.log('ww', this.list)
		}
	}
</script>

<style lang="scss" scoped>
	swiper {
		width: 750rpx;
		height: 470rpx;
		background-color: #F1ECE7;
	}

	swiper-item {
		width: 750rpx;
		height: 470rpx;
		background-color: #F1ECE7;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.header {
		position: fixed;
		top: 0;
		left: 0;
		width: 750rpx;
		height: 42rpx;
		display: flex;
		justify-content: start;

		.header1 {
			width: 320rpx;
			font-size: 12px;
			color: white;
		}

		.header2 {
			width: 90rpx;
		}

		image {
			width: 42rpx;
			height: 42rpx;
		}
	}

	.pltj {
		width: 750rpx;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		background-color: #F1ECE7;

		.pltj1 {
			line-height: 100rpx;
			font-weight: 600;
		}

		.pltj2 {
			line-height: 100rpx;
			color: grey;
		}
	}

	.xh1 {
		display: flex;
		justify-content: start;
		background-color: #F1ECE7;

	}

	.white {
		width: 208rpx;
		height: 210rpx;
		margin-left: 20px;

		image {
			width: 200rpx;
			height: 176rpx;
			text-align: center;
		}

		view {
			text-align: center;
		}
	}
	.bg{
		position: relative;
		display: flex;
		justify-content: space-around;
		width: 642rpx;
		height: 130px;
		background-color: white;
		margin: 30px auto;
		border-radius: 5px;
		.img{
			position: absolute;
			left: 10px;
			bottom: 10px;
			width: 194rpx;
			height: 140px;
			border-radius: 5px;
			
		}
	}
	.color-item {
		width: 20rpx;
		height: 20rpx;
		border-radius: 50%;
	}
</style>
